﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com
using System;
using System.Windows;

namespace WebCamViewer
{
    public class WebCamWindowHandler
    {
        protected Window _parentWindow;
        public WebCamWindow _window;

        public WebCamWindowHandler(Window parentWindow)
        {
            _parentWindow = parentWindow;
        }

        public void CreateWindow(Window owner)
        {
            if (_window == null)
            {
                _window = new WebCamWindow() { Owner = owner };
                _window.Closed += new EventHandler(_window_Closed);
            }
            
            _window.Show();
            _window.Focus();
        }
        
        private void _window_Closed(object sender, EventArgs e)
        {
            _window.Closed -= _window_Closed;
            _window = null;
        }
    }
}
